package com.hns.its.service.driverAdmin;

import com.hns.its.dao.IItsOrgEmployeeLeaveDao;
import com.hns.its.domain.ItsSysUserLeaveEntity;
import com.hns.its.domain.ItsTransportDriverEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 请假业务层实现类
 *
 * @author xuy
 * @email 609784814@qq.com
 * @Date 2017年5月19日 上午10:05:12
 */
@Service
@Transactional(readOnly = true)
public class ItsOrgEmployeeLeaveService {
	private static final Logger logger = LoggerFactory.getLogger(ItsSysUserLeaveEntity.class);

	@Autowired
	private IItsOrgEmployeeLeaveDao iItsOrgEmployeeLeaveDao;

	/**
	 * 请假完成列表
	 *
	 * @param
	 */
	public List<ItsSysUserLeaveEntity> complateList() {
		List<ItsSysUserLeaveEntity> list = iItsOrgEmployeeLeaveDao.applyLeave();
		List<ItsSysUserLeaveEntity> result = new ArrayList<>();
		for (int i = 0; i < list.size(); i++) {
			ItsSysUserLeaveEntity temp = list.get(i);
			if ( temp.getEndTime().compareTo(new Date()) <=0) {
				result.add(temp);
			}
		}
		return result;
	}

	/**
	 * 申请同意列表
	 *
	 * @param
	 */
	public List<ItsSysUserLeaveEntity> applyLeave() {
		List<ItsSysUserLeaveEntity> list = iItsOrgEmployeeLeaveDao.applyLeave();
		List<ItsSysUserLeaveEntity> result = new ArrayList<>();
		for (int i = 0; i < list.size(); i++) {
			ItsSysUserLeaveEntity temp = list.get(i);
			if (temp.getBeginTime().compareTo(new Date()) <= 0 && temp.getEndTime().compareTo(new Date()) > 0) {
				result.add(temp);
			}
		}
		return result;
	}


}
